import {RequestMapping} from "../../server/support/anno/RequestMapping"
import {Controller} from "../../server/web/_Controller"
import {Component} from "../../server/support/anno/Component"
import {getConnection} from "typeorm"
import {User} from "../entity/User"

const userDao = getConnection().getRepository(User)


@Component()
class UserController extends Controller{
  static context = "/user"

  @RequestMapping("/{id}")
  async get(req: HttpRequest, resp) {
    const {id} = req.params
    const ret = await userDao.findOne(id)
    return {
      data: ret,
      code: 200
    }
  }
}
